package com.atguigu.tms.mock.mapper;

import com.atguigu.tms.mock.bean.BaseOrgan;
import com.atguigu.tms.mock.mapper.adv.AdvMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 机构范围表 Mapper 接口
 * </p>
 *
 * @author zhangchen
 * @since 2022-06-13
 */
public interface BaseOrganMapper extends AdvMapper<BaseOrgan> {


    @Select(" SELECT concat(prov.name, city.name,dist.name,'转运站' ) org_name , 2  org_level ,     dist.id  region_id ,#{parentOrgan.id} org_parent_id  , now() create_time " +
            " FROM base_region_info dist ,base_region_info city , base_region_info prov " +
            "  WHERE  dist.dict_code='District'  AND city.dict_code='City' AND prov.dict_code='Province'  " +
            "  AND dist.parent_id=city.id AND city.parent_id = prov.id and  city.id = #{parentOrgan.regionId}  ")
    public List<BaseOrgan> selectBaseOrganDistList(@Param("parentOrgan") BaseOrgan   parentOrgan);

    @Select(" SELECT concat(prov.name, city.name ,'转运中心' ) org_name , 1  org_level  ,  city.id  region_id ,  now() create_time FROM   " +
            "  base_region_info city , base_region_info prov " +
            "  WHERE    city.dict_code='City' AND prov.dict_code='Province' " +
            "    AND city.parent_id = prov.id and  city.id in (${cityId}) ")
    public List<BaseOrgan> selectBaseOrganCityList(@Param("cityId") String cityId);
}
